{php include wl_template('common/header');}
<div class="page-group">
    <div class="page page-current" id="page-address">
    	<header class="bar bar-nav">
			<a class="button button-link button-nav pull-left" href="{$bakurl}"><span class="icon icon-left"></span>返回</a>
			<h1 class="title">我的地址</h1>
			<a class="button button-link button-nav pull-right" href="{php echo app_url('address/createadd/display',array('isshop'=>$isshop,'goodsid'=>$goodsid,'tuan_id'=>$tuan_id,'groupnum'=>$groupnum,'num'=>$_GPC['num']));}">新增</a>
		</header>
		<div class="content">
			<div class="list-block media-list">
		      <ul>
		      	{loop $address $addres}
		        <li class="item-content" >
		        	{if empty($goodsid)}
		        	<div class="item-media">{if $addres['status'] == 1}<i class="weui_icon_success"></i>{else}<i class="weui_icon_success_circle"></i>{/if}</div>
		        	{/if}
		            <div class="item-inner">
		              <div class="item-title-row">
		                <div class="item-title">{$addres['cname']} - {$addres['tel']}</div>
		                <div class="item-after"><a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default">{if $addres['type'] == 2}家庭{else}公司{/if}</a></div>
		              </div>
		              <div class="item-subtitle" style="padding: 0.4rem 0;">{$addres['province']}{$addres['city']}{$addres['county']}{$addres['detailed_address']}</div>
		            
		              <div class="item-title-row">
		                <div class="item-title addset" id="{$addres['id']}">{if $addres['status'] == 1}默认地址{/if}</div>
		                <div class="item-after">
		                	<p class="buttons-row">{if $addres['status'] == 0}<a href="{php echo app_url('address/addmanage/select',array('id'=>$addres['id'],'isshop'=>$isshop,'goodsid'=>$goodsid,'tuan_id'=>$tuan_id,'groupnum'=>$groupnum,'num'=>$_GPC['num']));}" class="button external">选择</a>{/if}<a href="{php echo app_url('address/createadd/display',array('id'=>$addres['id'],'isshop'=>$isshop,'goodsid'=>$goodsid,'tuan_id'=>$tuan_id,'groupnum'=>$groupnum,'num'=>$_GPC['num']));}" class="button external">编辑</a><a href="#" class="button adddel" addid='{$addres['id']}'>删除</a></p>
		                </div>
		              </div>
		              
		            </div>
		        </li>
		        {/loop}
		      </ul>
		    </div>
		</div>
	</div>
</div>
<script>
	$(function() {
		'use strict';
		//地址列表
		$(document).on("pageInit", "#page-address", function(e, id, page) {
			var $content = $(page).find('.content');
			$content.on('click','.adddel', function () {
				var id = $(this).attr('addid');
			    $.confirm('确认删除收货地址吗?',
			        function () {
			          $.post("{php echo app_url('address/createadd/deletes',array('isshop'=>$isshop,'goodsid'=>$goodsid,'tuan_id'=>$tuan_id,'groupnum'=>$groupnum,'num'=>$_GPC['num']))}",{id:id},function(d){
							if(d.status == 1){
							    $.alert('地址删除成功', function () {
							        location.href = "{php echo app_url('address/addmanage',array('isshop'=>$isshop,'goodsid'=>$goodsid,'tuan_id'=>$tuan_id,'groupnum'=>$groupnum,'num'=>$_GPC['num']))}";
							    });
							}else{
								$.toast(d.result);
							}
						},"json");
			        }
			    );
			});    
		});
		$.init();
	});
</script>
{php include wl_template('common/footer');}